﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using PicStore.BLL.Register;
using PicStore.Common.Ioc;
using PicStore.Common.Log;

namespace PicStore.Server
{
    partial class PicStoreService : ServiceBase
    {
        public PicStoreService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            var container = UnityContainerInstance.Instance;
            Bootstrapper.ConfigureUnity(container);
            ServiceRegistry.Register(container);

            var log = ObjectFactory.GetInstance<ILog>();
            try
            {
                log.Info("服务初始化");
                Thread.Sleep(50000);
                RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
            }
            catch (Exception ex)
            {
                log.Severe("PicStoreService无法启动", ex);
                throw;
            }
        }

        protected override void OnStop()
        {
            // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
        }
    }
}
